﻿using System.Collections.Specialized;
using System.Web.Mvc;

namespace E_Ticaret.Models
{
    public class DefaultFilter
    {
        public string SearchSreing { get; set; }
        public AlanEnum Alan { get; set; }
        public SiralamaEnum Sirala { get; set; }
    }

    public static class UrlCreater
    {
        public static MvcHtmlString Create(AlanEnum alan, NameValueCollection collection)
        {
            var dir = "asc";
            var tag = new TagBuilder("a");
            var value = collection.Get("Sirala");
            if (!string.IsNullOrEmpty(value))
            {
                if (value == "asc")
                    dir = "desc";
            }
            tag.Attributes.Add("href", "/Product/Index?" + "Alan=" + alan + "&Sirala=" + dir);
            switch (alan)
            {
                case AlanEnum.Price:
                    tag.SetInnerText("Fiyata Göre Sırala");
                    break;
                case AlanEnum.Model:
                    tag.SetInnerText("Modele Göre Sırala");
                    break;
                case AlanEnum.Title:
                    tag.SetInnerText("Başlığa Göre Sırala");
                    break;
            }
            return new MvcHtmlString(tag.ToString());
        }
    }
}